﻿@using CollegeShop.Infrastructure.Entities.Enum
@{
    ViewBag.Title = "List";
    Layout = "~/Views/Shared/_Default.cshtml";
}
@section head{
    <style type="text/css">
        body
        {
            background-color: #fff;
        }
    </style>
}
<div class="container-fluid" style="padding:20px 50px;">
    <div class="page-header">
        <h1>
            我的订单 
        </h1>
    </div>
    <div class="row-fluid" style="min-height:480px;">
        <div class="span12">
            <div class="widget-box">
                <div class="widget-header header-color-blue2">
                    <h4>
                        <i class="icon-user bigger-110"></i> 所有订单
                    </h4>
                </div>
                @{
                    CollegeShop.Infrastructure.Entities.ItemListBox<CollegeShop.Infrastructure.Entities.Entity.Orderdetail> data = ViewBag.Data;
                    }
                <div class="widget-body">
                    <ul id="tasks" class="item-list ui-sortable">
                    @{
                        if(data != null && data.Data != null && data.Data.Any())
                        {
                            foreach(var item in data.Data)
                            {
				                <li class="item-orange clearfix">
                                    <div class="row-fluid line80">
                                        <div class="span4">
                                            <img style="width:80px; height:80px;" class="commodity-small" src="@item.Goods.Resource.Path" alt="@item.Goods.GoodsTitel" />
                                            <div class="inline">
                                                <a href="javascript:;">@item.Goods.GoodsTitel (@item.Goods.Style)</a>
                                            </div>
                                        </div>
                                        <div class="span2">
                                            @(item.GoodsAmount)件 （@item.Goods.Standard * @item.GoodsAmount）
                                        </div>
                                        <div class="span2">
                                            <label class="inline">
                                                合计：￥@item.GoodsPrice 元
                                            </label>
                                        </div>
                                        <div class="span2">
                                            @switch(item.OrderInfo.State){
                                                case OrderState.Cancel:
                                                    <i class="icon-off grey"></i> <span class="grey">@OrderState.Cancel.Mapping()</span>
                                                    break;
                                                case OrderState.Complete:
                                                    <i class="icon-ok green"></i> <span class="green">@OrderState.Complete.Mapping()</span>
                                                    break;
                                                case OrderState.Confirm:
                                                    <i class="icon-bell orange"></i> <span class="orange">@OrderState.Confirm.Mapping()</span>
                                                    break;
                                                case OrderState.Payed:
                                                    <i class="icon-bell orange"></i> <span class="orange">@OrderState.Payed.Mapping()</span>
                                                    break;
                                            }
                                            
                                        </div>
                                        <div class="span2" style="text-align:center;">
                                            <input type="button" class="btn btn-primary tobuy" commodity-id="@item.Goods.ID" commodity-price="@item.Goods.DefaultSalePrice" data-placement="top" 
                                            data-content="<div class=green style=line-height:40px>已添加至购物车，您可以通过购物车进行结算。</div><hr style='margin:0'/><div style=line-height:40px>您也可以 <a class='btn btn-danger btn-mini' href=/home/cart>立刻结算</a></div>" 
                                            data-html="true" data-trigger="click"
                                            value="再次购买" />
                                        </div>
                                    </div>
				                </li>
                            }
                        }
                        else
                        {
                            <li class="item-orange clearfix">
                                    <div class="row-fluid line80">
                                        <div class="span12">
                                            您（本账号）还没有购买过任何物品 <a href="/">立刻前往选购</a>
                                        </div>
                                    </div>
				                </li>
                        }
                        }
			        </ul>
                    <div class="form-actions" style="margin: 0; padding-top:0px; padding-bottom:0px; text-align:right;">
                        @Html.Raw(data.PageItemSegment)
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@section tail{
   <script type="text/javascript">
       var timeOutAction;
       $(function () {
           $('.tobuy').each(function () {
               $(this).popover();
               $(this).click(function (e) {
                   var commodityId = $(this).attr('commodity-id');

                   var cart = getCookie('goodscart');
                   if (!ishas(unescape(cart).split(','), commodityId)) {
                       var count = 0;
                       if (!cart) {
                           setCookie('goodscart', commodityId + ',');
                           count = 1;
                       }
                       else {
                           var goods = cart.split(',');
                           goods.push(commodityId);
                           goods = distinct(goods);
                           count = goods.length;
                           cart = goods.join();
                           setCookie('goodscart', cart);
                       }
                       $('#cmdcount').text(count);
                       if ($('.noncommodity').length > 0) {
                           $('.noncommodity').remove();
                       }

                       var img = $(this).parent().parent().children('div:eq(0)').children('img');
                       var title = $(this).parent().parent().children('div:eq(0)').children('div').children('a').text();
                       $('#cartbox').children('li.dropdown-header').after(
                        $('<li />').append(
                            $('<a href="javascript:;" />').append(
                                $('<img alt="' + img.attr('alt') + '" src="' + img.attr('src') + '" class="msg-photo" />')
                            ).append(
                                $('<span class="msg-body" />').append(
                                    $('<span class="msg-title">' + title + '</span>')
                                ).append(
                                    $('<span class="msg-time" />').append(
                                        $('<i class="icon-angle-right"></i>&nbsp;')
                                    ).append(
                                        $('<span class="red bolder">' + $(this).attr('commodity-price') + '</span>')
                                    )
                                )
                            ))
                    );
                   }
                   if (e && e.preventDefault) {
                       e.preventDefault();
                   } else {
                       window.event.returnValue = false;
                   }
                   return false;
               });
           });
           $('body').click(function () {
               if ($('.popover-content').length != 0) {
                   $('.tobuy').popover('hide');
               }
           });
       });
   </script>
}